/**************************************************************
 * @file     Boot_Manager.h
 * @brief    Bootloader跳转相关函数
 * @author   Ruilist
 * @date     2025-08-15
 * @version  V1.0.0
 * @copyright Copyright (c) 2025
 *
 * @note     1 tab = 4 space
 *
 * @par 日志:
 * - V1.0.0 2025-08-15 Ruilist
 **************************************************************/

#ifndef __BOOT_MANAGER_H
#define __BOOT_MANAGER_H

//******************************** Includes *********************************//

#include "main.h"
#include "flash.h"
#include "w25qxx_handler.h"
#include "elog.h"
#include "AES.h"
#include "AT24Cxx_Driver.h"
#include "gpio.h"
#include "ymodem.h"

//******************************** Includes *********************************//

//******************************** Defines **********************************//

#define APPLICATION_ADDRESS      0x8008000
#define BACK_APPLICATION_ADDRESS 0x8020000
#define NVIC_VECT_TAB_FLASH      ( (uint32_t)0x08000000 )

#define NO_APP_UPDATE            0x00
#define APP_DOWNLOADING          0x11
#define APP_DOWNLOAD_COMPLETE    0x22

typedef void ( *pFunction )( void );

extern uint8_t Ymodem_rec[1024];  // ymodem接收缓存数组

//******************************** Defines **********************************//

//******************************** Declaring ********************************//

void   JumpToApp( void );
void   OTA_state_manager( void );
int8_t ExA_To_ExB_AES( int32_t fl_size );
uint32_t ExB_To_App( void );
int8_t ExA_To_App( void );
int8_t App_To_ExA( int32_t fl_size );

//******************************** Declaring ********************************//
#endif  // End of __BOOT_MANAGER_H
